package com.sc.nft.controller;

import com.sc.nft.annotation.UserLogin;
import com.sc.nft.controller.request.IdRequest;
import com.sc.nft.entity.dto.AcquisitionActivityDTO;
import com.sc.nft.entity.vo.AcquisitionActivityVO;
import com.sc.nft.service.PrizeDrawActivityService;
import com.sc.nft.sup.PageResult;
import com.sc.nft.sup.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 抽奖活动(PrizeDrawActivity)表控制层
 *
 * @author wwc
 * @since 2023-08-22 15:14:46
 */

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("prizeDrawActivity")
@Api(tags = "抽奖活动")
public class PrizeDrawActivityController {

    /**
     * 服务对象
     */
    private final PrizeDrawActivityService prizeDrawActivityService;

    @PostMapping(value = "/acquisitionActivity", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "获取活动", notes = "获取活动", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @UserLogin
    public PageResult<AcquisitionActivityVO> acquisitionActivity(@Valid @RequestBody AcquisitionActivityDTO acquisitionActivityDTO) {
        return PageResult.success(prizeDrawActivityService.acquisitionActivity(acquisitionActivityDTO));
    }


    @PostMapping(value = "/getById", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "根据ID获取独立活动", notes = "根据ID获取独立活动", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @UserLogin
    public Result<AcquisitionActivityVO> getById(@RequestBody IdRequest idRequest) {
        return Result.success(prizeDrawActivityService.getByIdDetails(idRequest.getId()));
    }

}
